Skip to main content

Wait

Polling helpers for waiting on a condition of the process image.

The overloads taking a Platform sleep on it between polls; the ones without sleep on the default (std::thread-backed) platform and so exist only on hosted runtimes.

Example
 bool waitWithPlatform(Robotiq::Gripper& gripper, uint8_t target)
 {
  bool settled = Robotiq::waitFor([&] { return gripper.getStatus().positionRequestEcho == target; },
  gripper.platform(),
  std::chrono::seconds(1));
  return settled;
 }

Members

Functions
boolwaitUntil (Predicate predicate, Platform &platform, std::chrono::steady_clock::time_point deadline, std::chrono::milliseconds pollPeriod=std::chrono::milliseconds(2))

Poll predicate until it holds, or deadline passes. More...

boolwaitFor (Predicate predicate, Platform &platform, std::chrono::milliseconds timeout, std::chrono::milliseconds pollPeriod=std::chrono::milliseconds(2))

Poll predicate until it holds, or timeout elapses. More...

boolwaitUntil (Predicate predicate, std::chrono::steady_clock::time_point deadline, std::chrono::milliseconds pollPeriod=std::chrono::milliseconds(2))
boolwaitFor (Predicate predicate, std::chrono::milliseconds timeout, std::chrono::milliseconds pollPeriod=std::chrono::milliseconds(2))

Functions

waitFor()

template <typename Predicate>
bool Robotiq::waitFor(Predicatepredicate,
Platform &platform,
std::chrono::millisecondstimeout,
std::chrono::millisecondspollPeriod = std::chrono::milliseconds(2)
)

Poll predicate until it holds, or timeout elapses.

Template Parameters
Predicate

A callable taking no arguments, returning bool.

Parameters
predicate

The condition to wait for.

platform

Supplies the sleep between polls.

timeout

How long to wait, starting now.

pollPeriod

How long to sleep between polls.

Returns

true if predicate held within timeout; false on timeout.

waitFor()

template <typename Predicate>
bool Robotiq::waitFor(Predicatepredicate,
std::chrono::millisecondstimeout,
std::chrono::millisecondspollPeriod = std::chrono::milliseconds(2)
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sleeps on the default (std::thread-backed) platform. Hosted-only.

waitUntil()

template <typename Predicate>
bool Robotiq::waitUntil(Predicatepredicate,
Platform &platform,
std::chrono::steady_clock::time_pointdeadline,
std::chrono::millisecondspollPeriod = std::chrono::milliseconds(2)
)

Poll predicate until it holds, or deadline passes.

predicate is evaluated at least once, even past the deadline: an already-true condition never reports a timeout.

Template Parameters
Predicate

A callable taking no arguments, returning bool.

Parameters
predicate

The condition to wait for.

platform

Supplies the sleep between polls.

deadline

The time point past which waiting gives up.

pollPeriod

How long to sleep between polls.

Returns

true if predicate held before deadline; false on timeout.

waitUntil()

template <typename Predicate>
bool Robotiq::waitUntil(Predicatepredicate,
std::chrono::steady_clock::time_pointdeadline,
std::chrono::millisecondspollPeriod = std::chrono::milliseconds(2)
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sleeps on the default (std::thread-backed) platform. Hosted-only.


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.